<?php
        global $Room;
        $id=$data2['room'];

        if($Room[$id]['time3']==0){
            cleardjs($Room[$id]['djs'],$id);
            return false;
        }
        cleardjs($Room[$id]['djs'],$id);

        $Room[$id]['time3']=0;
        $Room[$id]['xx']['zt']='4';

        $bank=array();
        $user=array();

        if($Room[$id]['type']==7 || ($Room[$id]['type']==6 && $Room[$id]['bank'])){
            foreach ($Room[$id]['user'] as $connection3) {
                if($connection3->user['zt']=='1'){
                    $user[]=$connection3->user;
                }
            }
            if($Room[$id]['user'][$Room[$id]['bank']['id']]->user['zt']=='1'){
                $Room[$id]['bank']['id']=$Room[$id]['bank']['id'];
                $Room[$id]['bank']['index']=$Room[$id]['user'][$Room[$id]['bank']['id']]->user['index'];
            }
            else{
                $xz=rand(0,count($user)-1);
                $Room[$id]['bank']=$user[$xz];
            }

            $data=array();
            $Room[$id]['time4']=time();
            $data['act']='initxian';
            $data['room']=$id;
            reqact($data,'');
            return false;
        }

        if($Room[$id]['type']==6){
            $wz='go';
        }
        else{
            $wz='rob';
        }
        
        foreach ($Room[$id]['user'] as $connection3) {
                if($connection3->user['zt']=='1' && $connection3->user['qbank']=='-1'){
                    $msg=array();
                    $msg['id']='operationButton';
                    $img='/app/img/bull9/bull_text_not'.$wz.'.png';
                    $msg['html']='<div id="jiurenniuniu-qiangzhuangs" class="jiurenniuniu-qiangzhuangs" style="display: block;">
                    <img class="jiurenniuniu-qiangzhuangs-img" src="/app/img/bull9/bull_text_not'.$wz.'.png">
                 </div>';
                 $mp3='buqiang';
                    act('html',$msg,$connection3);
                    $msg=array();
                    $msg['index']=$connection3->user['index'];
                    $msg['img']=$img;
                    foreach ($Room[$id]['user'] as $connection4) {
                        if($connection4->user['online']!='-1'){
                            act('mp3play',$mp3,$connection4);
                        }
                        if($connection3->user['id']!=$connection4->user['id'] && $connection4->user['online']!='-1'){
                            act('showmemberRobText',$msg,$connection4);
                        }
                    }
                }
                print_r($connection3->user['qbank']);
                if($connection3->user['qbank']==$Room[$id]['beishu'] && $connection3->user['zt']==1){
                    $bank[]=$connection3->user;
                }
                if($connection3->user['zt']=='1'){
                    $user[]=$connection3->user;
                }
        }

        if(!$bank){
            $bank=$user;
        }
        $dataxx=array();
        foreach ($bank as $key => $value) {
            $dataxx[]=$value['index'];
        }
        arsort($dataxx);
        $dataxx2=array();
        foreach ($dataxx as $key => $value) {
            $dataxx2[]=$value;
        }
        $data=array();
        $data['user']=$dataxx2;
        $data['index']=$dataxx2[0];
        if(count($bank)!=1){
            foreach ($Room[$id]['user'] as $connection3) {
                            act('showqz',$data,$connection3);
            }
        }
        //生成庄家
        if(!$bank){
            $xz=rand(0,count($user)-1);
            $Room[$id]['bank']=$user[$xz];

        }
        else{
            $xz=rand(0,count($bank)-1);
            $Room[$id]['bank']=$bank[$xz];
        }


        if(count($bank)==1){
                    $Room[$id]['time4']=time();
                    $data=array();
                    $data['act']='initxian';
                    $data['room']=$id;
                    reqact($data,'');
        }
        else{
          $time_interval = 3;
          $Room[$id]['time4']=time()+$time_interval;
          djs($time_interval,'initxian',$id);
     }
        //闲家下注
        // $data=array();
        // $data['act']='initxian';
        // $data['room']=$id;
        // reqact($data,'');
